package cn.wolfcode.web.controller;

import cn.wolfcode.qo.JsonResult;
import cn.wolfcode.qo.QueryObject;
import cn.wolfcode.service.IPermissionService;
import cn.wolfcode.util.RequiredPermission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by wolfcode-lanxw
 */
@Controller
@RequestMapping("/permission")
public class PermissionController {
    @Autowired
    private IPermissionService permissionService;
    @RequestMapping("/list")
    public String list(QueryObject qo, Model model){
        model.addAttribute("pageInfo",permissionService.selectList(qo));
        return "permission/list";
    }
    @RequiredPermission(name = "权限加载",expression = "permission.reload")
    @RequestMapping("/reload")
    @ResponseBody
    public JsonResult reload(){
        int i = 1/0;
        //加载所有controller中的注解信息，封装成Permission对象，插入数据库中.
        permissionService.reload();
        return new JsonResult();
    }
}
